﻿/************************************************************************
 * SMLib - State Model Library
 * Copyright (C) 2012-2013 Ali Khalili (khalili_DOT_ir_@SIGN_gmail_DOT_com)
 * **********************************************************************
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License (LGPL) published 
 * by the Free Software Foundation; either version 2.1 of the License, or (at your
 * option) any later version. This program is distributed without any
 * warranty. See the GNU Lesser General Public License for more details. 
 * ***********************************************************************
 * File         :     SMLib\Storage\CTMC.cs
 * Description  :     Implementation of BDD Structure: Used in model checking engine - MCGine
 *                    (c) Ali Khalili and Amir Jalaly
 * Change log   :     -Jan 2012: some mofifications
 *                    -2011:  Initial version
 * To Do        :     1-Use this instead of previous class and structures (DONE!)
 *                    2-Remove the second algorithm for state space generation
 *                    3-On the fly computation of rewards
 ************************************************************************/
using System;
using System.Collections.Generic;
using System.Reflection;
using SMLib.Utils;
using SMLib.Base;


namespace SMLib.Storage
{
	#region CTMC State
	/// <summary>
	/// This is the container of a CTMC state.
	/// </summary>
	public class CTMCState //: 
	//IStateContainer,
	//DiGraph<CTMCState.Transition,CTMCState>
	{
	/// <summary>
	/// We just store the rate and the destinationContent
	/// </summary>
	public class Transition //: 
	    //ITransition,
	    //ITransition<CTMCState>
	{
	    double rate;
	    CTMCState dst;
	    public Transition(double rate, CTMCState dst)
	    {
	        this.rate = rate;
	        this.dst = dst;
	    }
	    public double Rate
	    {
	        get
	        {
	            return rate;
	        }
	        set
	        {
	            rate = value;
	        }
	    }
	
	    #region Itransition Members
	    public CTMCState Destination
	    {
	        get { return dst; }
	    }
	    #endregion
	
	    
	}
	
	//[To Do]Not efficient. Compute rewards on the fly!
	public SortedList<string, double> rewardsvalue = new SortedList<string, double>();
	public double probability = 0;
	
	object cnt;
	public int id;
	List<object> trs;
	
	public static string modelid = "";
	
	public CTMCState(int id, object cont)
	{
	    this.cnt = cont;
	    this.id = id;
	    trs = new List<object>();
	}
	
	#region IStateContainer Members
	
	public object Identifier
	{
	    get { return id; }
	}
	
	public /*IStateContent*/ object content
	{
	    get { return /*(IStateContent)*/cnt; }
	}
	
	public string ModelName
	{
	    get { return modelid; }
	}
	
	public List<object> Transitions
	{
	    get { return trs; }
	}
	#endregion
	
	
	
	
	}
	
	#endregion
}
